import java.util.Scanner;

import javax.swing.JOptionPane;


public class Driver {

	public static int gcd(int x, int y){
		int gcd=0;
		if(y==0){
			return x;
		}
		else{
			gcd=gcd(y, x%y);
		}
		return gcd;
	}
	
	
	public static void main(String[] args){
		Scanner keyboard=new Scanner(System.in);
		String input="";
		Character isLetter=new Character(' ');
		int firstNumber=0;
		int secondNumber=0;
		boolean isContinue;
		boolean isTrue=true;
		int gcd=0;
		
		JOptionPane.showMessageDialog(null, "Welcome to the Greatest Common \n Denominator Program.");
		while(isTrue){
			
		isContinue=true;
		
		while(isContinue){
		try{
		input=JOptionPane.showInputDialog("Please enter the first integer");
		
		for(int i=0; i<input.length(); i++){
			if(!Character.isDigit(input.charAt(i))){
				throw new InvalidIntegerException();
			}
		}
		firstNumber=Integer.parseInt(input);
		
		isContinue=false;
		}catch(InvalidIntegerException iie){
			
		}
	
	}
		isContinue=true;

	while(isContinue){
		try{
		input=JOptionPane.showInputDialog("Please enter the second integer");
		
		for(int i=0; i<input.length(); i++){
			if(!Character.isDigit(input.charAt(i))){
				throw new InvalidIntegerException();
			}
		}
		secondNumber=Integer.parseInt(input);
		
		isContinue=false;
		}catch(InvalidIntegerException iie){
			
		}
		
	}
	gcd=gcd(firstNumber,secondNumber);
	JOptionPane.showMessageDialog(null, "The greatest common denomiantor of "+firstNumber+" and "+
			secondNumber+" is:	"+gcd);
	
	input=JOptionPane.showInputDialog("Do you want to compute another GCD?(Yes/No)");
	if(input.equalsIgnoreCase("Yes") || input.equalsIgnoreCase("Y")){
		
	}
	else{
		isTrue=false;
	}
		}
}


	
}